<link type="text/css" rel="stylesheet" href="<?php echo $this->assetDirWeb ?>js/Webmaster/custom.js" />

<div class="span6">
    <div class="control-group">
        <?php echo $form->labelEx($model, 'firstname', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            echo $form->textField($model, 'firstname', array(
                'placeholder' => $model->getAttributeLabel('firstname'),
                'class'       => 'input-file uniform_on input-reset'))
            ?>
            <font color="red"> <?php echo $form->error($model, 'firstname'); ?> </font>
        </div>
    </div>
    <div class="control-group">
        <?php echo $form->labelEx($model, 'lastname', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            echo $form->textField($model, 'lastname', array(
                'class'        => 'input-file uniform_on input-reset',
                'placeholder'  => $model->getAttributeLabel('lastname'),
                'autocomplete' => 'off'
            ))
            ?>
            <font color="red"> <?php echo $form->error($model, 'lastname'); ?> </font>
        </div>
    </div>

    <div class="control-group">
        <?php echo $form->labelEx($model, 'nickname', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            echo $form->textField($model, 'nickname', array(
                'class'        => 'input-file uniform_on input-reset',
                'placeholder'  => $model->getAttributeLabel('nickname'),
                'autocomplete' => 'off'
            ))
            ?>
            <font color="red"> <?php echo $form->error($model, 'nickname'); ?> </font>
        </div>
    </div>

    <div class="control-group">
        <?php echo $form->labelEx($model, 'description', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            echo $form->textArea($model, 'description', array(
                'class'       => 'input-file uniform_on input-reset',
                'placeholder' => $model->getAttributeLabel('description'),))
            ?>
            <font color="red"> <?php echo $form->error($model, 'description'); ?> </font>
        </div>
    </div>
    <div class="control-group">
        <?php echo $form->labelEx($model, 'birthday', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            $birthdayOpts = array(
                'class'       => 'datepicker',
                'placeholder' => $model->getAttributeLabel('birthday'),
                'readonly'    => true,
            );

            if ($model->birthday)
            {
                $birthdayOpts['value'] = @date('d/M/Y', $model->birthday);
            }

            echo $form->textField($model, 'birthday', $birthdayOpts)
            ?>
            <font color="red"> <?php echo $form->error($model, 'birthday'); ?> </font>
        </div>
    </div>

    <?php
    if ($model->type == Users::TYPE_STAFF or $model->type == Users::TYPE_CUSTOMER)
    {
        //Staff và customer có thêm 2 thông tin Gender và Note
        ?>

        <div class="control-group">
            <?php echo $form->labelEx($model, 'gender', array('class' => 'control-label')) ?>
            <div class ="controls">
                <?php echo $form->dropDownList($model, 'gender', Users::getGender()); ?>
                <font color="red"> <?php echo $form->error($model, 'gender'); ?> </font>
            </div>
        </div>

        <div class="control-group">
            <?php echo $form->labelEx($model, 'note', array('class' => 'control-label')) ?>
            <div class ="controls">
                <?php
                echo $form->textArea($model, 'note', array(
                    'class'       => 'input-file uniform_on input-reset',
                    'placeholder' => $model->getAttributeLabel('note'),))
                ?>
                <font color="red"> <?php echo $form->error($model, 'note'); ?> </font>
            </div>
        </div>
    <?php } ?>

    <div class="control-group">
        <?php echo $form->labelEx($model, 'address', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            echo $form->textField($model, 'address', array(
                'class'       => 'input-file uniform_on input-reset',
                'placeholder' => $model->getAttributeLabel('address')))
            ?>
            <font color="red"> <?php echo $form->error($model, 'address'); ?> </font>
        </div>
    </div>
    <div class="control-group">
        <?php echo $form->labelEx($model, 'address2', array('class' => 'control-label')); ?>
        <div class ="controls">
            <?php
            echo $form->textField($model, 'address2', array(
                'placeholder' => '(Optional)',
                'class'       => 'input-file uniform_on input-reset'
            ));
            ?>
            <font color="red"><?php echo $form->error($model, 'address2'); ?></font>
        </div>
    </div>
    <div class="control-group">
        <?php echo $form->labelEx($model, 'country', array('class' => 'control-label')); ?>
        <div class ="controls">                                    
            <?php echo $form->dropDownList($model, 'country', Country::getAllCountry(), array('options' => array('SGP' => array('selected' => true)))); ?>
            <font color="red"><?php echo $form->error($model, 'country'); ?></font>
        </div>
    </div>
    <div class="control-group">
        <?php echo $form->labelEx($model, 'postal_code', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            echo $form->textField($model, 'postal_code', array(
                'class'       => 'input-file uniform_on input-reset',
                'placeholder' => $model->getAttributeLabel('postal_code')))
            ?>
            <font color="red"> <?php echo $form->error($model, 'postal_code'); ?> </font>
        </div>
    </div>
    <div class="control-group">
        <?php echo $form->labelEx($model, 'home_phone', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            echo $form->textField($model, 'home_phone', array(
                'class'       => 'input-file uniform_on input-reset',
                'placeholder' => $model->getAttributeLabel('home_phone')))
            ?>
            <font color="red"> <?php echo $form->error($model, 'home_phone'); ?> </font>
        </div>
    </div>

    <div class="control-group">
        <?php echo $form->labelEx($model, 'office_phone', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            echo $form->textField($model, 'office_phone', array(
                'class'       => 'input-file uniform_on input-reset',
                'placeholder' => $model->getAttributeLabel('office_phone')))
            ?>
            <font color="red"> <?php echo $form->error($model, 'office_phone'); ?> </font>
        </div>
    </div>
    <div class="control-group">
        <?php echo $form->labelEx($model, 'mobile_phone', array('class' => 'control-label')) ?>
        <div class ="controls">
            <?php
            echo $form->textField($model, 'mobile_phone', array(
                'class'       => 'input-file uniform_on input-reset',
                'placeholder' => $model->getAttributeLabel('mobile_phone')))
            ?>
            <font color="red"> <?php echo $form->error($model, 'mobile_phone'); ?> </font>
        </div>
    </div>
    <?php if ($model->type == Users::TYPE_STAFF): ?>
        <!--Nếu là Staff có thêm trường author_id-->
        <?php if (Yii::app()->controller->isAdmin): ?>
            <!--Nếu là Admin thì có Select Merchant-->
            <div class="control-group">
                <?php echo $form->labelEx($model, 'author_id', array('class' => 'control-label')) ?>
                <div class ="controls">                
                    <?php
                    echo $form->dropDownList($model, 'author_id', Users::getAllBussiness(), array(
                        'data-rel'         => "chosen",
                        'data-placeholder' => "Type Merchant name...",
                    ));
                    ?>
                    <font color="red"> <?php echo $form->error($model, 'author_id'); ?> </font>
                </div>
            </div>
        <?php elseif (!$this->isBranch && $this->isBussiness): ?>
            <!--Nếu là Root Merchant có Select Branch-->
            <div class="control-group">
                <label class="control-label">Select Branch</label>
                <div class ="controls">                
                    <?php
                    echo $form->dropDownList($model, 'author_id', Merchant::getListBranch(Yii::app()->user->id, FALSE), array(
                        'data-rel'         => "chosen",
                        'data-placeholder' => "Type Merchant name...",
                    ));
                    ?>
                    <font color="red"> <?php echo $form->error($model, 'author_id'); ?> </font>
                </div>
            </div>
        <?php endif; ?>
    <?php endif; ?>

    <?php if ($model->type == Users::TYPE_CUSTOMER): ?>
        <?php if (Yii::app()->controller->isBussiness): ?>
            <!--Nếu là Staff có thêm trường author_id-->
            <div class="control-group">
                <?php echo $form->labelEx($model, 'author_id', array('class' => 'control-label')) ?>
                <div class ="controls">               
                    <?php
                    $authorData = Users::getAllStaffOfBusiness();
                    ?>
                    <?php
                    echo $form->dropDownList($model, 'author_id', $authorData, array(
                        'data-rel'         => "chosen",
                        'data-placeholder' => "Type Merchant name...",
                    ));
                    ?>
                    <font color="red"> <?php echo $form->error($model, 'author_id'); ?> </font>
                </div>
            </div>
        <?php elseif (Yii::app()->controller->isAdmin): ?>
            <div class="control-group">
                <?php echo $form->labelEx($model, 'author_id', array('class' => 'control-label')) ?>
                <div class ="controls">               

                    <?php $authorData = CHtml::listData(Users::getAllStaffAndBiz(), 'id', 'name', 'group');
                    ?>

                    <?php
                    echo $form->dropDownList($model, 'author_id', $authorData, array(
                        'data-rel'         => "chosen",
                        'data-placeholder' => "Type Merchant name...",
                    ));
                    ?>
                    <font color="red"> <?php echo $form->error($model, 'author_id'); ?> </font>
                </div>
            </div>
        <?php endif; ?>
    <?php endif; ?>
</div>
